package thread;

public class Demo10 {
    private static boolean isFinished = false;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while(!isFinished){
                System.out.println("hello");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("结束");
        });

        //打印3~4次hello
        t.start();

        Thread.sleep(3000);
        isFinished = true;
    }
}
